package project.dade.cn.bst.adapter.base;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;



import java.util.List;

import project.dade.cn.bst.R;

public class TimeAdapter extends BaseAdapter{

	private List<String> times;
	private Context context;
	private ViewHolder viewHolder = null;

	public TimeAdapter(Context context, List<String> times){
		this.times = times;
		this.context = context;
	}

	@Override
	public int getCount() {
		if(times != null && ! times.isEmpty()){
			return times.size();
		}
		return 0;
	}

	@Override
	public Object getItem(int arg0) {
		return times.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		View viewRoot = convertView;
		if (viewRoot == null) {
			viewRoot = LayoutInflater.from(context).inflate(R.layout.time_adapter, null);
			viewHolder = new ViewHolder();
			viewHolder.time_adapter_txt = (TextView) viewRoot.findViewById(R.id.time_adapter_txt);
			viewRoot.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) viewRoot.getTag();
		}
		viewHolder.time_adapter_txt.setText(times.get(position));
		return viewRoot;
	}

	class ViewHolder{

		TextView time_adapter_txt;

	}

}
